package routers

import (
	"github.com/gin-gonic/gin"
	"leading/global"
	"leading/middleware"
)

type RouterGroup struct {
	*gin.RouterGroup
}

func InitRouter() *gin.Engine {
	gin.SetMode(global.Config.System.Env)

	router := gin.Default()
	// 解决跨越的问题
	//router.Use(cors)
	// 权限中间件
	router.Use(middleware.AuthMiddle())
	routerGroup := router.Group("api")
	routerGroupApp := RouterGroup{routerGroup}
	routerGroupApp.UserRouter()
	routerGroupApp.FileRouter()
	routerGroupApp.ShareRouter()
	router.Run(":8080")
	return router
}
